using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using T2.WebSecurity.ASPMVC.Entity;
using T2.WebSecurity.ASPMVC.Entity.Interface;
using T2.WebSecurity.Business.Entities.Interfaces;
using T2.WebSecurity.Business.Entities;
using T2.WebSecurity.ASPMVC.Entity.Translators;

//--Change Management Control - Membership ASPMVC Entity Translator  --**********************
//--Created By: James Rooks
//--Description: Membership Translator
//--Created Date: 02/05/2013 18:24:14
//--*************************************************************
namespace T2.WebSecurity.ASPMVC.Entity.Translators
{
	public class MembershipUITranslator 
	{
		public IMembership_biz TranslateToBusinessLayer(IMembership_ui _translateFrom)
        {
            IMembership_biz temp = new Membership_biz();
		
			if(_translateFrom != null)
			{
			    temp.Action = _translateFrom.Action;
                temp.Caller = _translateFrom.Caller;
                temp.Role = _translateFrom.Role;
                temp.PageSize = _translateFrom.PageSize;
                temp.PageNumber = _translateFrom.PageNumber;
                temp.SortColumn = _translateFrom.SortColumn;
                temp.SortType = _translateFrom.SortType;
                temp.TotalRows = _translateFrom.TotalRows;
			if (_translateFrom.MembershipID != null)
			{
				temp.MembershipID = _translateFrom.MembershipID;
			}
			else
			{
			temp.MembershipID = -1;
			}
			if (_translateFrom.ConfirmationToken != null)
			{
				temp.ConfirmationToken = _translateFrom.ConfirmationToken;
			}
			else
			{
			temp.ConfirmationToken = String.Empty;
			}
			if (_translateFrom.IsConfirmed != null)
			{
				temp.IsConfirmed = _translateFrom.IsConfirmed;
			}
			else
			{
			temp.IsConfirmed = false;
			}
			if (_translateFrom.LastPasswordFailureDate != null)
			{
				temp.LastPasswordFailureDate = _translateFrom.LastPasswordFailureDate;
			}
			else
			{
			temp.LastPasswordFailureDate = Convert.ToDateTime(@"01\01\1753");
			}
			if (_translateFrom.PasswordFailuresSinceLastSuccess != null)
			{
				temp.PasswordFailuresSinceLastSuccess = _translateFrom.PasswordFailuresSinceLastSuccess;
			}
			else
			{
			temp.PasswordFailuresSinceLastSuccess = -1;
			}
			if (_translateFrom.Password != null)
			{
				temp.Password = _translateFrom.Password;
			}
			else
			{
			temp.Password = String.Empty;
			}
			if (_translateFrom.PasswordChangedDate != null)
			{
				temp.PasswordChangedDate = _translateFrom.PasswordChangedDate;
			}
			else
			{
			temp.PasswordChangedDate = Convert.ToDateTime(@"01\01\1753");
			}
			if (_translateFrom.PasswordSalt != null)
			{
				temp.PasswordSalt = _translateFrom.PasswordSalt;
			}
			else
			{
			temp.PasswordSalt = String.Empty;
			}
			if (_translateFrom.PasswordVerificationToken != null)
			{
				temp.PasswordVerificationToken = _translateFrom.PasswordVerificationToken;
			}
			else
			{
			temp.PasswordVerificationToken = String.Empty;
			}
			if (_translateFrom.PasswordVerificationTokenExpirationDate != null)
			{
				temp.PasswordVerificationTokenExpirationDate = _translateFrom.PasswordVerificationTokenExpirationDate;
			}
			else
			{
			temp.PasswordVerificationTokenExpirationDate = Convert.ToDateTime(@"01\01\1753");
			}
			if (_translateFrom.TS != null)
			{
				temp.TS = TranslatorHelper.TranslateTimeStampToBusiness(_translateFrom.TS);
			}
			if (_translateFrom.CreatedBy != null)
			{
				temp.CreatedBy = _translateFrom.CreatedBy;
			}
			else
			{
			temp.CreatedBy = String.Empty;
			}
			if (_translateFrom.CreatedDt != null)
			{
				temp.CreatedDt = _translateFrom.CreatedDt;
			}
			else
			{
			temp.CreatedDt = Convert.ToDateTime(@"01\01\1753");
			}
			if (_translateFrom.ModifiedBy != null)
			{
				temp.ModifiedBy = _translateFrom.ModifiedBy;
			}
			else
			{
			temp.ModifiedBy = String.Empty;
			}
			if (_translateFrom.ModifiedDt != null)
			{
				temp.ModifiedDt = _translateFrom.ModifiedDt;
			}
			else
			{
			temp.ModifiedDt = Convert.ToDateTime(@"01\01\1753");
			}
			if (_translateFrom.EmailAccount != null)
			{
				temp.EmailAccount = _translateFrom.EmailAccount;
			}
			else
			{
			temp.EmailAccount = String.Empty;
			}
			if (_translateFrom.PasswordAnswer != null)
			{
				temp.PasswordAnswer = _translateFrom.PasswordAnswer;
			}
			else
			{
			temp.PasswordAnswer = String.Empty;
			}
			if (_translateFrom.LastLoginDate != null)
			{
				temp.LastLoginDate = _translateFrom.LastLoginDate;
			}
			else
			{
			temp.LastLoginDate = Convert.ToDateTime(@"01\01\1753");
			}
			if (_translateFrom.LastLockoutDate != null)
			{
				temp.LastLockoutDate = _translateFrom.LastLockoutDate;
			}
			else
			{
			temp.LastLockoutDate = Convert.ToDateTime(@"01\01\1753");
			}
			if (_translateFrom.UserId != null)
			{
				temp.UserId = _translateFrom.UserId;
			}
			else
			{
			temp.UserId = -1;
			}
			if (_translateFrom.PasswordQuestionID != null)
			{
				temp.PasswordQuestionID = _translateFrom.PasswordQuestionID;
			}
			else
			{
			temp.PasswordQuestionID = -1;
			}
			UserProfileUITranslator UserProfileUITranslator = new UserProfileUITranslator();
			temp.UserProfile =UserProfileUITranslator.TranslateToBusinessLayer(_translateFrom.UserProfile);
			PasswordQuestionUITranslator PasswordQuestionUITranslator = new PasswordQuestionUITranslator();
			temp.PasswordQuestion =PasswordQuestionUITranslator.TranslateToBusinessLayer(_translateFrom.PasswordQuestion);
			
			
			}
			return temp;
			
		}
		
		public IMembership_ui TranslateFromBusinessLayer(IMembership_biz _translateFrom)
        {
            IMembership_ui temp = new Membership_ui();
		
			if(_translateFrom != null)
			{
			    temp.Action = _translateFrom.Action;
                temp.Caller = _translateFrom.Caller;
                temp.Role = _translateFrom.Role;
                temp.PageSize = _translateFrom.PageSize;
                temp.PageNumber = _translateFrom.PageNumber;
                temp.SortColumn = _translateFrom.SortColumn;
                temp.SortType = _translateFrom.SortType;
                temp.TotalRows = _translateFrom.TotalRows;
			if (_translateFrom.MembershipID != null)
			{
				temp.MembershipID = _translateFrom.MembershipID;
			}
			else
			{
			temp.MembershipID = -1;
			}
			if (_translateFrom.ConfirmationToken != null)
			{
				temp.ConfirmationToken = _translateFrom.ConfirmationToken;
			}
			else
			{
			temp.ConfirmationToken = String.Empty;
			}
			if (_translateFrom.IsConfirmed != null)
			{
				temp.IsConfirmed = _translateFrom.IsConfirmed;
			}
			else
			{
			temp.IsConfirmed = false;
			}
			if (_translateFrom.LastPasswordFailureDate != null)
			{
				temp.LastPasswordFailureDate = _translateFrom.LastPasswordFailureDate;
			}
			else
			{
			temp.LastPasswordFailureDate = Convert.ToDateTime(@"01\01\1753");
			}
			if (_translateFrom.PasswordFailuresSinceLastSuccess != null)
			{
				temp.PasswordFailuresSinceLastSuccess = _translateFrom.PasswordFailuresSinceLastSuccess;
			}
			else
			{
			temp.PasswordFailuresSinceLastSuccess = -1;
			}
			if (_translateFrom.Password != null)
			{
				temp.Password = _translateFrom.Password;
			}
			else
			{
			temp.Password = String.Empty;
			}
			if (_translateFrom.PasswordChangedDate != null)
			{
				temp.PasswordChangedDate = _translateFrom.PasswordChangedDate;
			}
			else
			{
			temp.PasswordChangedDate = Convert.ToDateTime(@"01\01\1753");
			}
			if (_translateFrom.PasswordSalt != null)
			{
				temp.PasswordSalt = _translateFrom.PasswordSalt;
			}
			else
			{
			temp.PasswordSalt = String.Empty;
			}
			if (_translateFrom.PasswordVerificationToken != null)
			{
				temp.PasswordVerificationToken = _translateFrom.PasswordVerificationToken;
			}
			else
			{
			temp.PasswordVerificationToken = String.Empty;
			}
			if (_translateFrom.PasswordVerificationTokenExpirationDate != null)
			{
				temp.PasswordVerificationTokenExpirationDate = _translateFrom.PasswordVerificationTokenExpirationDate;
			}
			else
			{
			temp.PasswordVerificationTokenExpirationDate = Convert.ToDateTime(@"01\01\1753");
			}
			if (_translateFrom.TS != null)
			{
				temp.TS = TranslatorHelper.TranslateTimeStampFromBusiness(_translateFrom.TS);
			}
			if (_translateFrom.CreatedBy != null)
			{
				temp.CreatedBy = _translateFrom.CreatedBy;
			}
			else
			{
			temp.CreatedBy = String.Empty;
			}
			if (_translateFrom.CreatedDt != null)
			{
				temp.CreatedDt = _translateFrom.CreatedDt;
			}
			else
			{
			temp.CreatedDt = Convert.ToDateTime(@"01\01\1753");
			}
			if (_translateFrom.ModifiedBy != null)
			{
				temp.ModifiedBy = _translateFrom.ModifiedBy;
			}
			else
			{
			temp.ModifiedBy = String.Empty;
			}
			if (_translateFrom.ModifiedDt != null)
			{
				temp.ModifiedDt = _translateFrom.ModifiedDt;
			}
			else
			{
			temp.ModifiedDt = Convert.ToDateTime(@"01\01\1753");
			}
			if (_translateFrom.EmailAccount != null)
			{
				temp.EmailAccount = _translateFrom.EmailAccount;
			}
			else
			{
			temp.EmailAccount = String.Empty;
			}
			if (_translateFrom.PasswordAnswer != null)
			{
				temp.PasswordAnswer = _translateFrom.PasswordAnswer;
			}
			else
			{
			temp.PasswordAnswer = String.Empty;
			}
			if (_translateFrom.LastLoginDate != null)
			{
				temp.LastLoginDate = _translateFrom.LastLoginDate;
			}
			else
			{
			temp.LastLoginDate = Convert.ToDateTime(@"01\01\1753");
			}
			if (_translateFrom.LastLockoutDate != null)
			{
				temp.LastLockoutDate = _translateFrom.LastLockoutDate;
			}
			else
			{
			temp.LastLockoutDate = Convert.ToDateTime(@"01\01\1753");
			}
			if (_translateFrom.UserId != null)
			{
				temp.UserId = _translateFrom.UserId;
			}
			else
			{
			temp.UserId = -1;
			}
			if (_translateFrom.PasswordQuestionID != null)
			{
				temp.PasswordQuestionID = _translateFrom.PasswordQuestionID;
			}
			else
			{
			temp.PasswordQuestionID = -1;
			}
			UserProfileUITranslator UserProfileUITranslator = new UserProfileUITranslator();
			temp.UserProfile =UserProfileUITranslator.TranslateFromBusinessLayer(_translateFrom.UserProfile);
			PasswordQuestionUITranslator PasswordQuestionUITranslator = new PasswordQuestionUITranslator();
			temp.PasswordQuestion =PasswordQuestionUITranslator.TranslateFromBusinessLayer(_translateFrom.PasswordQuestion);
			
			
			}
			return temp;
			
		}
	
	
	}


}